package com.banmao.wxnotebookserver.entity;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class R<T> {

    private int code;

    private String errorMsg = "";

    private T data;

    private String timestamp;

    //public void setTimestamp(String timestamp) {
    //    SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
    //    Date date = new Date();
    //    String dateStr = formatter.format(date);
    //    this.timestamp = dateStr;
    //}

    public String getTimestamp() {
        SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        Date date = new Date();
        String dateStr = formatter.format(date);
        return dateStr;
    }

    public void setTimestamp(Date date) {
        SimpleDateFormat formatter = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
        String dateStr = formatter.format(date);
        this.timestamp = dateStr;
    }
}
